package com.lykj.lib_base.adapter.viewpager

import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.viewpager.widget.PagerAdapter
import com.bumptech.glide.load.MultiTransformation
import com.bumptech.glide.load.resource.bitmap.FitCenter
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.lykj.lib_base.component.GlideApp
import com.lykj.lib_base.internal.inter.OnRemoteImageViewPagerTouchListener
import me.jessyan.autosize.utils.AutoSizeUtils

/**
 * ================================================
 * 远程图片viewpager适配器
 * ================================================
 *
 * @author gosha
 * @date 2023/11/30-11:05
 */
class RemoteImageViewPagerAdapter(data: ArrayList<ImageView>) : PagerAdapter() {
    private var mImages = data

    override fun getCount(): Int {
        if (mImages != null) {
            // 这里返回一个很大的数，表示可以翻转很多很多次（相当于实现图片无限翻转）。
            return Integer.MAX_VALUE;
        }
        return 0
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val realPosition = position % mImages.size
        container.addView(mImages[realPosition])

        Log.e("RIVPA","position:$position index:$realPosition")
        return mImages[realPosition]
    }


    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(`object` as View?)
    }

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        // 这里一般写成下面的样子就可以了
        return view === `object`
    }
}